package c.c.c.a.a;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.SystemClock;
import c.c.c.a.i.h;
import c.c.c.a.i.i;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.regex.Pattern;

/* compiled from: ANRManager */
public class a {
    public final Context a;
    public volatile long b;
    public volatile boolean c = false;
    public final SharedPreferences d;

    public a(Context context) {
        if (context == null || !(context instanceof Application)) {
            throw new IllegalArgumentException("context must not be null or not application");
        }
        this.a = context;
        SharedPreferences sharedPreferences = context.getSharedPreferences("anr_monitor_table", 0);
        this.d = sharedPreferences;
        this.b = sharedPreferences.getLong("trace_anr_happen_time", 0);
        int i = h.a;
        h.a = 100;
        h.d = (long) 100;
        h.b = new ArrayList();
        i.a(4);
        h.a().e();
        h a = h.a();
        e eVar = new e();
        synchronized (a) {
            a.e.add(eVar);
        }
        a = h.a();
        a.f.add(new f());
        h.g = h.e();
        h.h = SystemClock.uptimeMillis();
        h.a(h.c());
    }

    public final String a(BufferedReader bufferedReader) throws IOException {
        StringBuilder stringBuilder = new StringBuilder();
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine != null && readLine.trim().length() > 0) {
                stringBuilder.append(readLine);
                stringBuilder.append("\n");
            }
        }
        return stringBuilder.toString();
    }

    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:182:0x0451 A:{SYNTHETIC, Splitter:B:182:0x0451} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:182:0x0451 A:{SYNTHETIC, Splitter:B:182:0x0451} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:182:0x0451 A:{SYNTHETIC, Splitter:B:182:0x0451} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:182:0x0451 A:{SYNTHETIC, Splitter:B:182:0x0451} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:187:0x0459 A:{SYNTHETIC, Splitter:B:187:0x0459} */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x014d A:{Catch:{ Exception -> 0x0154 }} */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x0133 A:{SYNTHETIC, Splitter:B:57:0x0133} */
    /* JADX WARNING: Missing exception handler attribute for start block: B:54:0x012c */
    /* JADX WARNING: Removed duplicated region for block: B:182:0x0451 A:{SYNTHETIC, Splitter:B:182:0x0451} */
    /* JADX WARNING: Removed duplicated region for block: B:205:0x0502 A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x053f A:{Catch:{ all -> 0x0547 }} */
    /* JADX WARNING: Can't wrap try/catch for region: R(8:51|52|53|54|55|(3:57|58|229)(3:59|60|230)|228|48) */
    public boolean b(int r22, java.lang.String r23, int r24) {
        /*
        r21 = this;
        r1 = r21;
        r2 = c.c.c.a.f.ANR;
        r0 = c.c.c.a.a.h.a;
        r3 = new org.json.JSONArray;
        r3.<init>();
        r0 = c.c.c.a.a.h.b;
        r4 = 0;
        r5 = 1;
        if (r0 != 0) goto L_0x0013;
    L_0x0011:
        r0 = 0;
        goto L_0x0056;
    L_0x0013:
        c.c.c.a.a.h.m = r5;
        r0 = new java.util.ArrayList;
        r0.<init>();
        r6 = c.c.c.a.a.h.b;
        r6 = r6.size();
        r7 = c.c.c.a.a.h.a;
        if (r6 != r7) goto L_0x004f;
    L_0x0024:
        r6 = c.c.c.a.a.h.q;
    L_0x0026:
        r7 = c.c.c.a.a.h.b;
        r7 = r7.size();
        if (r6 >= r7) goto L_0x003c;
    L_0x002e:
        r7 = c.c.c.a.a.h.b;
        r7 = r7.get(r6);
        r7 = (c.c.c.a.a.h.a) r7;
        r0.add(r7);
        r6 = r6 + 1;
        goto L_0x0026;
    L_0x003c:
        r6 = 0;
    L_0x003d:
        r7 = c.c.c.a.a.h.q;
        if (r6 >= r7) goto L_0x0054;
    L_0x0041:
        r7 = c.c.c.a.a.h.b;
        r7 = r7.get(r6);
        r7 = (c.c.c.a.a.h.a) r7;
        r0.add(r7);
        r6 = r6 + 1;
        goto L_0x003d;
    L_0x004f:
        r6 = c.c.c.a.a.h.b;
        r0.addAll(r6);
    L_0x0054:
        c.c.c.a.a.h.m = r4;
    L_0x0056:
        if (r0 != 0) goto L_0x0059;
    L_0x0058:
        goto L_0x00ad;
    L_0x0059:
        r6 = r0.iterator();
        r0 = 0;
    L_0x005e:
        r7 = r6.hasNext();
        if (r7 == 0) goto L_0x00ad;
    L_0x0064:
        r7 = r6.next();
        r7 = (c.c.c.a.a.h.a) r7;
        if (r7 != 0) goto L_0x006d;
    L_0x006c:
        goto L_0x005e;
    L_0x006d:
        r8 = r0 + 1;
        r9 = new org.json.JSONObject;
        r9.<init>();
        r0 = "msg";
        r10 = r7.f;	 Catch:{ JSONException -> 0x00a4 }
        r9.put(r0, r10);	 Catch:{ JSONException -> 0x00a4 }
        r0 = "cpuDuration";
        r10 = r7.e;	 Catch:{ JSONException -> 0x00a4 }
        r9.put(r0, r10);	 Catch:{ JSONException -> 0x00a4 }
        r0 = "duration";
        r10 = r7.d;	 Catch:{ JSONException -> 0x00a4 }
        r9.put(r0, r10);	 Catch:{ JSONException -> 0x00a4 }
        r0 = "tick";
        r10 = r7.c;	 Catch:{ JSONException -> 0x00a4 }
        r9.put(r0, r10);	 Catch:{ JSONException -> 0x00a4 }
        r0 = "type";
        r10 = r7.b;	 Catch:{ JSONException -> 0x00a4 }
        r9.put(r0, r10);	 Catch:{ JSONException -> 0x00a4 }
        r0 = "count";
        r7 = r7.a;	 Catch:{ JSONException -> 0x00a4 }
        r9.put(r0, r7);	 Catch:{ JSONException -> 0x00a4 }
        r0 = "id";
        r9.put(r0, r8);	 Catch:{ JSONException -> 0x00a4 }
        goto L_0x00a8;
    L_0x00a4:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x00a8:
        r3.put(r9);
        r0 = r8;
        goto L_0x005e;
    L_0x00ad:
        r6 = android.os.SystemClock.uptimeMillis();
        r8 = new org.json.JSONObject;
        r8.<init>();
        r9 = 0;
        r0 = "message";
        r11 = c.c.c.a.a.h.l;	 Catch:{ all -> 0x00ff }
        r8.put(r0, r11);	 Catch:{ all -> 0x00ff }
        r0 = "currentMessageCost";
        r11 = c.c.c.a.a.h.o;	 Catch:{ all -> 0x00ff }
        r13 = (r11 > r9 ? 1 : (r11 == r9 ? 0 : -1));
        if (r13 >= 0) goto L_0x00d3;
    L_0x00c7:
        r9 = android.os.SystemClock.uptimeMillis();	 Catch:{ all -> 0x00ff }
        r11 = c.c.c.a.a.h.e;	 Catch:{ all -> 0x00ff }
        r9 = r9 - r11;
        r11 = c.c.c.a.a.h.p;	 Catch:{ all -> 0x00ff }
        r13 = c.c.c.a.a.h.d;	 Catch:{ all -> 0x00ff }
        goto L_0x00de;
    L_0x00d3:
        r9 = android.os.SystemClock.uptimeMillis();	 Catch:{ all -> 0x00ff }
        r11 = c.c.c.a.a.h.e;	 Catch:{ all -> 0x00ff }
        r9 = r9 - r11;
        r11 = c.c.c.a.a.h.o;	 Catch:{ all -> 0x00ff }
        r13 = c.c.c.a.a.h.d;	 Catch:{ all -> 0x00ff }
    L_0x00de:
        java.lang.Long.signum(r11);
        r11 = r11 * r13;
        r9 = r9 - r11;
        r8.put(r0, r9);	 Catch:{ all -> 0x00ff }
        r0 = "currentMessageCpu";
        r9 = c.c.c.a.a.h.e();	 Catch:{ all -> 0x00ff }
        r11 = c.c.c.a.a.h.g;	 Catch:{ all -> 0x00ff }
        r9 = r9 - r11;
        r8.put(r0, r9);	 Catch:{ all -> 0x00ff }
        r0 = "currentTick";
        r9 = c.c.c.a.a.h.c;	 Catch:{ all -> 0x00ff }
        r9 = r9.get();	 Catch:{ all -> 0x00ff }
        r8.put(r0, r9);	 Catch:{ all -> 0x00ff }
        goto L_0x0103;
    L_0x00ff:
        r0 = c.c.c.a.n.a;
        r0 = c.c.c.a.n.d;
    L_0x0103:
        r9 = c.c.c.a.a.h.c();
        r10 = new org.json.JSONArray;
        r10.<init>();
        if (r9 != 0) goto L_0x010f;
    L_0x010e:
        goto L_0x0157;
    L_0x010f:
        monitor-enter(r9);
        r0 = c.c.c.a.a.h.a(r9);	 Catch:{ all -> 0x054d }
        if (r0 != 0) goto L_0x0118;
    L_0x0116:
        monitor-exit(r9);	 Catch:{ all -> 0x054d }
        goto L_0x0157;
    L_0x0118:
        r11 = 0;
        r12 = 0;
    L_0x011a:
        r13 = 100;
        if (r0 == 0) goto L_0x0156;
    L_0x011e:
        if (r11 >= r13) goto L_0x0156;
    L_0x0120:
        r11 = r11 + 1;
        r12 = r12 + r5;
        r13 = c.c.c.a.a.h.b(r0, r6);	 Catch:{ all -> 0x054d }
        r14 = "id";
        r13.put(r14, r12);	 Catch:{ JSONException -> 0x012c }
    L_0x012c:
        r10.put(r13);	 Catch:{ all -> 0x054d }
        r13 = c.c.c.a.a.h.t;	 Catch:{ all -> 0x054d }
        if (r13 != 0) goto L_0x014d;
    L_0x0133:
        r13 = "android.os.Message";
        r13 = java.lang.Class.forName(r13);	 Catch:{ Exception -> 0x0154 }
        r14 = "next";
        r13 = r13.getDeclaredField(r14);	 Catch:{ Exception -> 0x0154 }
        c.c.c.a.a.h.t = r13;	 Catch:{ Exception -> 0x0154 }
        r13.setAccessible(r5);	 Catch:{ Exception -> 0x0154 }
        r13 = c.c.c.a.a.h.t;	 Catch:{ Exception -> 0x0154 }
        r0 = r13.get(r0);	 Catch:{ Exception -> 0x0154 }
        r0 = (android.os.Message) r0;	 Catch:{ Exception -> 0x0154 }
        goto L_0x011a;
    L_0x014d:
        r0 = r13.get(r0);	 Catch:{ Exception -> 0x0154 }
        r0 = (android.os.Message) r0;	 Catch:{ Exception -> 0x0154 }
        goto L_0x011a;
    L_0x0154:
        r0 = 0;
        goto L_0x011a;
    L_0x0156:
        monitor-exit(r9);	 Catch:{ all -> 0x054d }
    L_0x0157:
        r0 = c.c.c.a.a.c.a();	 Catch:{ JSONException -> 0x015d }
    L_0x015b:
        r5 = r0;
        goto L_0x0164;
    L_0x015d:
        r0 = move-exception;
        r5 = r0;
        r5.printStackTrace();
        r0 = 0;
        goto L_0x015b;
    L_0x0164:
        r0 = r1.a;
        r6 = "activity";
        r0 = r0.getSystemService(r6);
        r0 = (android.app.ActivityManager) r0;
        r6 = 2;
        if (r0 != 0) goto L_0x0172;
    L_0x0171:
        goto L_0x019a;
    L_0x0172:
        r7 = 0;
        r9 = r24;
    L_0x0175:
        if (r7 >= r9) goto L_0x019a;
    L_0x0177:
        r11 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
        android.os.SystemClock.sleep(r11);
        r11 = r0.getProcessesInErrorState();
        if (r11 == 0) goto L_0x0197;
    L_0x0182:
        r11 = r11.iterator();
    L_0x0186:
        r12 = r11.hasNext();
        if (r12 == 0) goto L_0x0197;
    L_0x018c:
        r12 = r11.next();
        r12 = (android.app.ActivityManager.ProcessErrorStateInfo) r12;
        r13 = r12.condition;
        if (r13 == r6) goto L_0x019b;
    L_0x0196:
        goto L_0x0186;
    L_0x0197:
        r7 = r7 + 1;
        goto L_0x0175;
    L_0x019a:
        r12 = 0;
    L_0x019b:
        if (r12 == 0) goto L_0x0262;
    L_0x019d:
        r0 = android.os.Process.myPid();
        r6 = r12.pid;
        if (r0 != r6) goto L_0x0262;
    L_0x01a5:
        r0 = "|------------- processErrorStateInfo--------------|\n";
        r0 = c.b.a.a.a.g(r0);
        r6 = "condition: ";
        r6 = c.b.a.a.a.g(r6);
        r7 = r12.condition;
        r6.append(r7);
        r7 = "\n";
        r6.append(r7);
        r6 = r6.toString();
        r0.append(r6);
        r6 = new java.lang.StringBuilder;
        r6.<init>();
        r9 = "processName: ";
        r6.append(r9);
        r9 = r12.processName;
        r6.append(r9);
        r6.append(r7);
        r6 = r6.toString();
        r0.append(r6);
        r6 = new java.lang.StringBuilder;
        r6.<init>();
        r9 = "pid: ";
        r6.append(r9);
        r9 = r12.pid;
        r6.append(r9);
        r6.append(r7);
        r6 = r6.toString();
        r0.append(r6);
        r6 = new java.lang.StringBuilder;
        r6.<init>();
        r9 = "uid: ";
        r6.append(r9);
        r9 = r12.uid;
        r6.append(r9);
        r6.append(r7);
        r6 = r6.toString();
        r0.append(r6);
        r6 = new java.lang.StringBuilder;
        r6.<init>();
        r9 = "tag: ";
        r6.append(r9);
        r9 = r12.tag;
        r6.append(r9);
        r6.append(r7);
        r6 = r6.toString();
        r0.append(r6);
        r6 = new java.lang.StringBuilder;
        r6.<init>();
        r9 = "shortMsg : ";
        r6.append(r9);
        r9 = r12.shortMsg;
        r6.append(r9);
        r6.append(r7);
        r6 = r6.toString();
        r0.append(r6);
        r6 = new java.lang.StringBuilder;
        r6.<init>();
        r9 = "longMsg : ";
        r6.append(r9);
        r9 = r12.longMsg;
        r6.append(r9);
        r6.append(r7);
        r6 = r6.toString();
        r0.append(r6);
        r6 = "-----------------------end----------------------------";
        r0.append(r6);
        r0 = r0.toString();
        goto L_0x0263;
    L_0x0262:
        r0 = 0;
    L_0x0263:
        r6 = r0;
        r0 = android.text.TextUtils.isEmpty(r6);
        if (r0 == 0) goto L_0x026b;
    L_0x026a:
        return r4;
    L_0x026b:
        r0 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
        r4 = r22;
        if (r4 != r0) goto L_0x0468;
    L_0x0271:
        r0 = android.os.Process.myPid();
        r4 = r1.a;
        r4 = r4.getPackageName();
        r7 = "\\s";
        r9 = android.text.TextUtils.isEmpty(r23);
        if (r9 == 0) goto L_0x028c;
    L_0x0283:
        r17 = r2;
        r16 = r5;
        r24 = r6;
        r7 = r10;
        goto L_0x045d;
    L_0x028c:
        r9 = new java.io.File;
        r11 = r23;
        r9.<init>(r11);
        r11 = r9.exists();
        if (r11 == 0) goto L_0x0283;
    L_0x0299:
        r11 = r9.canRead();
        if (r11 != 0) goto L_0x02a0;
    L_0x029f:
        goto L_0x0283;
    L_0x02a0:
        r11 = new java.io.BufferedReader;	 Catch:{ Exception -> 0x0443, all -> 0x0440 }
        r12 = new java.io.FileReader;	 Catch:{ Exception -> 0x0443, all -> 0x0440 }
        r12.<init>(r9);	 Catch:{ Exception -> 0x0443, all -> 0x0440 }
        r11.<init>(r12);	 Catch:{ Exception -> 0x0443, all -> 0x0440 }
        r9 = "-{5}\\spid\\s\\d+\\sat\\s\\d+-\\d+-\\d+\\s\\d{2}:\\d{2}:\\d{2}\\s-{5}";
        r9 = java.util.regex.Pattern.compile(r9);	 Catch:{ Exception -> 0x043a }
        r12 = "-{5}\\send\\s\\d+\\s-{5}";
        r12 = java.util.regex.Pattern.compile(r12);	 Catch:{ Exception -> 0x043a }
        r13 = "Cmd\\sline:\\s(\\S+)";
        r13 = java.util.regex.Pattern.compile(r13);	 Catch:{ Exception -> 0x043a }
        r14 = "\".+\"\\s(daemon\\s){0,1}prio=\\d+\\stid=\\d+\\s.*";
        r14 = java.util.regex.Pattern.compile(r14);	 Catch:{ Exception -> 0x043a }
        r15 = new java.text.SimpleDateFormat;	 Catch:{ Exception -> 0x043a }
        r16 = r5;
        r5 = "yyyy-MM-dd HH:mm:ss";
        r17 = r2;
        r2 = java.util.Locale.US;	 Catch:{ Exception -> 0x0431 }
        r15.<init>(r5, r2);	 Catch:{ Exception -> 0x0431 }
        r2 = 1;
        r5 = new java.util.regex.Pattern[r2];	 Catch:{ Exception -> 0x0431 }
        r18 = 0;
        r5[r18] = r9;	 Catch:{ Exception -> 0x0431 }
        r5 = r1.c(r11, r5);	 Catch:{ Exception -> 0x0431 }
        if (r5 != 0) goto L_0x02e1;
    L_0x02dc:
        r24 = r6;
    L_0x02de:
        r7 = r10;
        goto L_0x042b;
    L_0x02e1:
        r2 = r5[r2];	 Catch:{ Exception -> 0x0431 }
        r2 = r2.toString();	 Catch:{ Exception -> 0x0431 }
        r2 = r2.split(r7);	 Catch:{ Exception -> 0x0431 }
        r9 = 2;
        r2 = r2[r9];	 Catch:{ Exception -> 0x0431 }
        r18 = java.lang.Long.parseLong(r2);	 Catch:{ Exception -> 0x0431 }
        r2 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x0431 }
        r2.<init>();	 Catch:{ Exception -> 0x0431 }
        r9 = 1;
        r9 = r5[r9];	 Catch:{ Exception -> 0x0431 }
        r9 = r9.toString();	 Catch:{ Exception -> 0x0431 }
        r9 = r9.split(r7);	 Catch:{ Exception -> 0x0431 }
        r20 = 4;
        r9 = r9[r20];	 Catch:{ Exception -> 0x0431 }
        r2.append(r9);	 Catch:{ Exception -> 0x0431 }
        r9 = " ";
        r2.append(r9);	 Catch:{ Exception -> 0x0431 }
        r9 = 1;
        r5 = r5[r9];	 Catch:{ Exception -> 0x0431 }
        r5 = r5.toString();	 Catch:{ Exception -> 0x0431 }
        r5 = r5.split(r7);	 Catch:{ Exception -> 0x0431 }
        r9 = 5;
        r5 = r5[r9];	 Catch:{ Exception -> 0x0431 }
        r2.append(r5);	 Catch:{ Exception -> 0x0431 }
        r2 = r2.toString();	 Catch:{ Exception -> 0x0431 }
        r2 = r15.parse(r2);	 Catch:{ Exception -> 0x0431 }
        r24 = r6;
        r5 = r2.getTime();	 Catch:{ Exception -> 0x042f }
        r2 = 1;
        r9 = new java.util.regex.Pattern[r2];	 Catch:{ Exception -> 0x042f }
        r15 = 0;
        r9[r15] = r13;	 Catch:{ Exception -> 0x042f }
        r9 = r1.c(r11, r9);	 Catch:{ Exception -> 0x042f }
        if (r9 != 0) goto L_0x033a;
    L_0x0339:
        goto L_0x02de;
    L_0x033a:
        r2 = r9[r2];	 Catch:{ Exception -> 0x042f }
        r2 = r2.toString();	 Catch:{ Exception -> 0x042f }
        r2 = r2.split(r7);	 Catch:{ Exception -> 0x042f }
        r7 = 2;
        r2 = r2[r7];	 Catch:{ Exception -> 0x042f }
        r7 = r10;
        r9 = (long) r0;
        r0 = (r18 > r9 ? 1 : (r18 == r9 ? 0 : -1));
        if (r0 != 0) goto L_0x042b;
    L_0x034d:
        r0 = r2.equalsIgnoreCase(r4);	 Catch:{ Exception -> 0x0429 }
        if (r0 != 0) goto L_0x0355;
    L_0x0353:
        goto L_0x042b;
    L_0x0355:
        r9 = r1.b;	 Catch:{ Exception -> 0x0429 }
        r18 = 0;
        r0 = (r9 > r18 ? 1 : (r9 == r18 ? 0 : -1));
        if (r0 == 0) goto L_0x036c;
    L_0x035d:
        r9 = r1.b;	 Catch:{ Exception -> 0x0429 }
        r9 = r9 - r5;
        r9 = java.lang.Math.abs(r9);	 Catch:{ Exception -> 0x0429 }
        r18 = 20000; // 0x4e20 float:2.8026E-41 double:9.8813E-320;
        r0 = (r9 > r18 ? 1 : (r9 == r18 ? 0 : -1));
        if (r0 >= 0) goto L_0x036c;
    L_0x036a:
        goto L_0x042b;
    L_0x036c:
        r1.b = r5;	 Catch:{ Exception -> 0x0429 }
        r0 = r1.d;	 Catch:{ Exception -> 0x0429 }
        if (r0 == 0) goto L_0x0381;
    L_0x0372:
        r0 = r0.edit();	 Catch:{ Exception -> 0x0429 }
        r2 = "trace_anr_happen_time";
        r9 = r1.b;	 Catch:{ Exception -> 0x0429 }
        r0 = r0.putLong(r2, r9);	 Catch:{ Exception -> 0x0429 }
        r0.apply();	 Catch:{ Exception -> 0x0429 }
    L_0x0381:
        r0 = new org.json.JSONObject;	 Catch:{ Exception -> 0x0429 }
        r0.<init>();	 Catch:{ Exception -> 0x0429 }
        r2 = "anrTime";
        r0.put(r2, r5);	 Catch:{ Exception -> 0x0429 }
        r2 = 2;
    L_0x038c:
        r4 = new java.util.regex.Pattern[r2];	 Catch:{ Exception -> 0x0429 }
        r5 = 0;
        r4[r5] = r12;	 Catch:{ Exception -> 0x0429 }
        r6 = 1;
        r4[r6] = r14;	 Catch:{ Exception -> 0x0429 }
        r4 = r1.c(r11, r4);	 Catch:{ Exception -> 0x0429 }
        if (r4 == 0) goto L_0x0419;
    L_0x039a:
        r5 = r4[r5];	 Catch:{ Exception -> 0x0429 }
        if (r5 != r14) goto L_0x0419;
    L_0x039e:
        r5 = "";
        r6 = "\".+\"";
        r6 = java.util.regex.Pattern.compile(r6);	 Catch:{ Exception -> 0x0429 }
        r9 = 1;
        r9 = r4[r9];	 Catch:{ Exception -> 0x0429 }
        r9 = r9.toString();	 Catch:{ Exception -> 0x0429 }
        r6 = r6.matcher(r9);	 Catch:{ Exception -> 0x0429 }
        r9 = r6.find();	 Catch:{ Exception -> 0x0429 }
        if (r9 == 0) goto L_0x03c9;
    L_0x03b7:
        r5 = r6.group();	 Catch:{ Exception -> 0x0429 }
        r6 = r6.group();	 Catch:{ Exception -> 0x0429 }
        r6 = r6.length();	 Catch:{ Exception -> 0x0429 }
        r9 = 1;
        r6 = r6 - r9;
        r5 = r5.substring(r9, r6);	 Catch:{ Exception -> 0x0429 }
    L_0x03c9:
        r6 = "tid=\\d+";
        r6 = java.util.regex.Pattern.compile(r6);	 Catch:{ Exception -> 0x0429 }
        r9 = 1;
        r4 = r4[r9];	 Catch:{ Exception -> 0x0429 }
        r4 = r4.toString();	 Catch:{ Exception -> 0x0429 }
        r4 = r6.matcher(r4);	 Catch:{ Exception -> 0x0429 }
        r6 = r4.find();	 Catch:{ Exception -> 0x0429 }
        r9 = -1;
        if (r6 == 0) goto L_0x03f6;
    L_0x03e1:
        r4 = r4.group();	 Catch:{ Exception -> 0x0429 }
        r6 = "=";
        r6 = r4.indexOf(r6);	 Catch:{ Exception -> 0x0429 }
        r6 = r6 + 1;
        r4 = r4.substring(r6);	 Catch:{ Exception -> 0x0429 }
        r4 = java.lang.Integer.parseInt(r4);	 Catch:{ Exception -> 0x0429 }
        goto L_0x03f7;
    L_0x03f6:
        r4 = -1;
    L_0x03f7:
        r6 = r1.a(r11);	 Catch:{ Exception -> 0x0429 }
        if (r4 == r9) goto L_0x038c;
    L_0x03fd:
        r4 = android.text.TextUtils.isEmpty(r5);	 Catch:{ Exception -> 0x0429 }
        if (r4 != 0) goto L_0x038c;
    L_0x0403:
        r4 = android.text.TextUtils.isEmpty(r6);	 Catch:{ Exception -> 0x0429 }
        if (r4 == 0) goto L_0x040a;
    L_0x0409:
        goto L_0x038c;
    L_0x040a:
        r4 = "main";
        r4 = r5.equalsIgnoreCase(r4);	 Catch:{ Exception -> 0x0429 }
        if (r4 == 0) goto L_0x038c;
    L_0x0412:
        r2 = "mainStackFromTrace";
        r0.put(r2, r6);	 Catch:{ Exception -> 0x0429 }
        r2 = 1;
        goto L_0x041a;
    L_0x0419:
        r2 = 0;
    L_0x041a:
        if (r2 != 0) goto L_0x041d;
    L_0x041c:
        goto L_0x042b;
    L_0x041d:
        r2 = "thread_number";
        r4 = 1;
        r0.put(r2, r4);	 Catch:{ Exception -> 0x0429 }
        r11.close();	 Catch:{ all -> 0x0427 }
        goto L_0x045e;
        goto L_0x045e;
    L_0x0429:
        r0 = move-exception;
        goto L_0x044c;
    L_0x042b:
        r11.close();	 Catch:{ all -> 0x045d }
        goto L_0x045d;
    L_0x042f:
        r0 = move-exception;
        goto L_0x0434;
    L_0x0431:
        r0 = move-exception;
    L_0x0432:
        r24 = r6;
    L_0x0434:
        r7 = r10;
        goto L_0x044c;
    L_0x0436:
        r0 = move-exception;
        r17 = r2;
        goto L_0x0432;
    L_0x043a:
        r0 = move-exception;
        r17 = r2;
        r16 = r5;
        goto L_0x0432;
    L_0x0440:
        r0 = move-exception;
        r2 = 0;
        goto L_0x0457;
    L_0x0443:
        r0 = move-exception;
        r17 = r2;
        r16 = r5;
        r24 = r6;
        r7 = r10;
        r11 = 0;
    L_0x044c:
        r0.printStackTrace();	 Catch:{ all -> 0x0455 }
        if (r11 == 0) goto L_0x045d;
    L_0x0451:
        r11.close();	 Catch:{ all -> 0x045d }
        goto L_0x045d;
    L_0x0455:
        r0 = move-exception;
        r2 = r11;
    L_0x0457:
        if (r2 == 0) goto L_0x045c;
    L_0x0459:
        r2.close();	 Catch:{ all -> 0x045c }
    L_0x045c:
        throw r0;
    L_0x045d:
        r0 = 0;
    L_0x045e:
        if (r0 == 0) goto L_0x046f;
    L_0x0460:
        r2 = r0.length();
        if (r2 <= 0) goto L_0x046f;
    L_0x0466:
        r5 = r0;
        goto L_0x0471;
    L_0x0468:
        r17 = r2;
        r16 = r5;
        r24 = r6;
        r7 = r10;
    L_0x046f:
        r5 = r16;
    L_0x0471:
        if (r5 == 0) goto L_0x054b;
    L_0x0473:
        r0 = r5.length();
        if (r0 <= 0) goto L_0x054b;
    L_0x0479:
        r0 = "pid";
        r2 = android.os.Process.myPid();	 Catch:{ all -> 0x0547 }
        r5.put(r0, r2);	 Catch:{ all -> 0x0547 }
        r0 = "package";
        r2 = r1.a;	 Catch:{ all -> 0x0547 }
        r2 = r2.getPackageName();	 Catch:{ all -> 0x0547 }
        r5.put(r0, r2);	 Catch:{ all -> 0x0547 }
        r0 = "is_remote_process";
        r2 = 0;
        r5.put(r0, r2);	 Catch:{ all -> 0x0547 }
        r0 = new c.c.c.a.e.a;	 Catch:{ all -> 0x0547 }
        r2 = new org.json.JSONObject;	 Catch:{ all -> 0x0547 }
        r2.<init>();	 Catch:{ all -> 0x0547 }
        r0.m1059init(r2);	 Catch:{ all -> 0x0547 }
        r2 = "data";
        r4 = r5.toString();	 Catch:{ all -> 0x0547 }
        r0.b(r2, r4);	 Catch:{ all -> 0x0547 }
        r2 = "is_anr";
        r4 = 1;
        r4 = java.lang.Integer.valueOf(r4);	 Catch:{ all -> 0x0547 }
        r0.b(r2, r4);	 Catch:{ all -> 0x0547 }
        r2 = "timestamp";
        r4 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x0547 }
        r4 = java.lang.Long.valueOf(r4);	 Catch:{ all -> 0x0547 }
        r0.b(r2, r4);	 Catch:{ all -> 0x0547 }
        r2 = "event_type";
        r4 = "anr";
        r0.b(r2, r4);	 Catch:{ all -> 0x0547 }
        r2 = "history_message";
        r0.b(r2, r3);	 Catch:{ all -> 0x0547 }
        r2 = "current_message";
        r0.b(r2, r8);	 Catch:{ all -> 0x0547 }
        r2 = "pending_messages";
        r0.b(r2, r7);	 Catch:{ all -> 0x0547 }
        r2 = "anr_time";
        r3 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x0547 }
        r3 = java.lang.Long.valueOf(r3);	 Catch:{ all -> 0x0547 }
        r0.b(r2, r3);	 Catch:{ all -> 0x0547 }
        r2 = "crash_time";
        r3 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x0547 }
        r3 = java.lang.Long.valueOf(r3);	 Catch:{ all -> 0x0547 }
        r0.b(r2, r3);	 Catch:{ all -> 0x0547 }
        r2 = "anr_info";
        r3 = r24;
        r0.b(r2, r3);	 Catch:{ all -> 0x0547 }
        r2 = "all_thread_stacks";
        r4 = 0;
        r4 = b.i.b.f.m(r4);	 Catch:{ all -> 0x0547 }
        r0.b(r2, r4);	 Catch:{ all -> 0x0547 }
        r2 = c.c.c.a.i.a.e.e;	 Catch:{ all -> 0x0547 }
        if (r2 == 0) goto L_0x053f;
    L_0x0502:
        r2 = c.c.c.a.i.a.e.e;	 Catch:{ all -> 0x0547 }
        r4 = r17;
        r0 = r2.a(r4, r0);	 Catch:{ all -> 0x0547 }
        r2 = r1.a;	 Catch:{ all -> 0x0547 }
        r5 = "anr";
        r6 = 0;
        b.i.b.f.p(r2, r5, r6);	 Catch:{ all -> 0x0547 }
        r2 = c.c.c.a.o.a.b;	 Catch:{ all -> 0x0547 }
        if (r2 != 0) goto L_0x051f;
    L_0x0516:
        r2 = new c.c.c.a.o.a;	 Catch:{ all -> 0x0547 }
        r5 = c.c.c.a.n.a;	 Catch:{ all -> 0x0547 }
        r2.m1094init(r5);	 Catch:{ all -> 0x0547 }
        c.c.c.a.o.a.b = r2;	 Catch:{ all -> 0x0547 }
    L_0x051f:
        r2 = c.c.c.a.o.a.b;	 Catch:{ all -> 0x0547 }
        r0 = r0.a;	 Catch:{ all -> 0x0547 }
        r2.a(r0);	 Catch:{ all -> 0x0547 }
        r0 = c.c.c.a.n.e;	 Catch:{ all -> 0x0547 }
        r0 = r0.d;	 Catch:{ all -> 0x0547 }
        r0 = r0.iterator();	 Catch:{ all -> 0x0547 }
    L_0x052e:
        r2 = r0.hasNext();	 Catch:{ all -> 0x0547 }
        if (r2 == 0) goto L_0x054b;
    L_0x0534:
        r2 = r0.next();	 Catch:{ all -> 0x0547 }
        r2 = (c.c.c.a.j) r2;	 Catch:{ all -> 0x0547 }
        r5 = 0;
        r2.a(r4, r3, r5);	 Catch:{ all -> 0x0547 }
        goto L_0x052e;
    L_0x053f:
        r0 = new java.lang.IllegalArgumentException;	 Catch:{ all -> 0x0547 }
        r2 = "CrashContextAssembly not init";
        r0.<init>(r2);	 Catch:{ all -> 0x0547 }
        throw r0;	 Catch:{ all -> 0x0547 }
    L_0x0547:
        r0 = c.c.c.a.n.a;
        r0 = c.c.c.a.n.d;
    L_0x054b:
        r0 = 1;
        return r0;
    L_0x054d:
        r0 = move-exception;
        monitor-exit(r9);	 Catch:{ all -> 0x054d }
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.c.a.a.a.b(int, java.lang.String, int):boolean");
    }

    public final Object[] c(BufferedReader bufferedReader, Pattern... patternArr) throws IOException {
        if (patternArr.length > 0) {
            while (true) {
                try {
                    String readLine = bufferedReader.readLine();
                    if (readLine == null) {
                        break;
                    }
                    int length = patternArr.length;
                    int i = 0;
                    while (true) {
                        if (i < length) {
                            if (patternArr[i].matcher(readLine).matches()) {
                                return new Object[]{patternArr[i], readLine};
                            }
                            i++;
                        }
                    }
                } catch (Throwable unused) {
                }
            }
        }
        return null;
    }
}
